package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseReq;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.goodsbean.wxbean.GoodsCategoryVO;
import com.cskaoyan.bean.goodsbean.wxbean.GoodsCountVO;
import com.cskaoyan.bean.goodsbean.wxbean.HomeIndexVO;
import com.cskaoyan.bean.goodsbean.wxvo.GoodsListReq;
import com.cskaoyan.bean.goodsbean.wxvo.GoodsListVO;
import com.cskaoyan.bean.goodsbean.wxvo.RelatedGoodsVO;
import com.cskaoyan.bean.goodsbean.wxvo.WXGoodsDetailVO;
import com.cskaoyan.service.WXGoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: whyccz-mall-project
 * @description:
 * @create: 2021-06-07 14:46
 **/
@RestController
public class WXGoodsController {
	@Autowired
	WXGoodService wxGoodService;
	@RequestMapping("wx/home/index")
	public BaseRespVo homeIndex(){
		HomeIndexVO homeIndex=wxGoodService.getHomeIndex();
		return BaseRespVo.ok(homeIndex);
	}

	@RequestMapping("wx/goods/count")
	public BaseRespVo goodsCount(){
		GoodsCountVO goodsCountVO=wxGoodService.getGoodsCount();
		return BaseRespVo.ok(goodsCountVO);
	}

	//wx/goods/category?id=1008016
	@RequestMapping("wx/goods/category")
	public BaseRespVo getGoodsCategory(Integer id ){
		GoodsCategoryVO goodsCategory=wxGoodService.getGoodsCategory(id);
		return BaseRespVo.ok(goodsCategory);

	}

	///wx/goods/list?categoryId=1008016&page=1&size=100
	// /wx/goods/list?keyword=22&page=1&size=20&sort=name&order=desc&categoryId=0
	@RequestMapping("wx/goods/list")
	public BaseRespVo getGoodsList(GoodsListReq goodsListReq){
		GoodsListVO goodsListVO=wxGoodService.getGoodsList(goodsListReq);
		return BaseRespVo.ok(goodsListVO);
	}

	///wx/goods/detail?id=1043005
	@RequestMapping("wx/goods/detail")
	public BaseRespVo getGoodsDetail(Integer id){
		WXGoodsDetailVO wxGoodsDetailVO=wxGoodService.getGoodsDetail(id);
		return BaseRespVo.ok(wxGoodsDetailVO);
	}

	///wx/goods/related?id=1055016
	@RequestMapping("wx/goods/related")
	public BaseRespVo getRelated(Integer id){
		RelatedGoodsVO relatedGoodsVO=wxGoodService.getRelatedGoods(id);
		return BaseRespVo.ok(relatedGoodsVO);
	}


}
